<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>商店管理</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		.table td {
			vertical-align: middle;
		}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#listForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
        function updateSort() {
        	if(${fn:length(page.list)==0}){
        		alert("暂无可保存的信息.");
        		return;
        	}
	    	$("#listForm").attr("action", "${ctx}/ivm/business/hangstore/updateSort");
	    	$("#listForm").submit();
    	}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ivm/business/hangstore/list">商店列表</a></li>
		<shiro:hasPermission name="ivm:business:hangstore:edit"><li><a href="${ctx}/ivm/business/hangstore/form">商店添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="hangStore" action="${ctx}/ivm/business/hangstore/" method="post">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
	</form:form>
	<tags:message content="${message}"/>
	<form id="listForm" method="post">
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th width="149">封面</th>
				<th>店名</th>
				<th>链接地址</th>
				<th style="text-align:center;">排序</th>
				<th>状态</th>
				<shiro:hasPermission name="ivm:business:hangstore:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="hangStore">
			<tr>
				<td><a href="${ctx}/ivm/business/hangstore/form?id=${hangStore.id}"><img id="photo" src="${ctx}/download?filePath=${hangStore.logoUrl }" style="width:149px; height:84px;" /></a></td>
				<td><a href="${ctx}/ivm/business/hangstore/form?id=${hangStore.id}">${hangStore.classify.name}</a></td>
				<td style="width: 600px; word-break: break-all; word-wrap:break-word;">${hangStore.classify.shopUrl}</td>
				<td style="text-align:center; width: 105px;">
					<shiro:hasPermission name="ivm:business:hangstore:edit">
						<input type="hidden" name="ids" value="${hangStore.id}"/>
						<input name="sorts" type="text" value="${hangStore.sort}" style="width:50px;margin:0;padding:0;text-align:center;" class="required digits">
					</shiro:hasPermission>
					<shiro:lacksPermission name="ivm:business:hangstore:edit">
						${hangStore.sort}
					</shiro:lacksPermission>
				</td>
				<td style="color:${hangStore.status=='0'?'green':'red' }">${hangStore.status=='0'?'正常':'取消'}</td>
				<shiro:hasPermission name="ivm:business:hangstore:edit"><td>
    				<a href="${ctx}/ivm/business/hangstore/form?id=${hangStore.id}">修改</a>
					<a href="${ctx}/ivm/business/hangstore/delete?id=${hangStore.id}" onclick="return confirmx('确认要删除该商店吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</form>
	<div class="pagination">${page}</div>
	<shiro:hasPermission name="ivm:business:hangstore:edit">
	<div class="form-actions pagination-left">
	<input id="btnSubmit" class="btn btn-primary" type="button" value="保存排序" onclick="updateSort();"/>
	</div>
	</shiro:hasPermission>
</body>
</html>
